package thread.thread_pool;

import java.util.concurrent.ThreadPoolExecutor;

public class Test4 {
    public static void main(String[] args) {
        // 线程池拒绝策略
        /*

         */
        // 超出的任务直接丢弃并抛出异常
        ThreadPoolExecutor.AbortPolicy abortPolicy = new ThreadPoolExecutor.AbortPolicy();
        // 直接丢弃任务
        ThreadPoolExecutor.DiscardPolicy discardPolicy = new ThreadPoolExecutor.DiscardPolicy();
        // 丢弃等待时间最长的任务
        ThreadPoolExecutor.DiscardOldestPolicy discardOldestPolicy = new ThreadPoolExecutor.DiscardOldestPolicy();
        // 永远不丢弃任务，跳过阻塞队列，由随机一条线程处理（影响性能）
        ThreadPoolExecutor.CallerRunsPolicy callerRunsPolicy = new ThreadPoolExecutor.CallerRunsPolicy();
    }
}
